import Vue from 'vue'
import Vuex from 'vuex'
import router from "../router";
// import permission from "./modules/permission"
// import user from "./modules/user";

Vue.use(Vuex)



export default new Vuex.Store({


  state: {
    user: JSON.parse(localStorage.getItem("user")||'{}')
  },
  mutations: {
    login(state,obj){
      //重新赋值
      localStorage.setItem("user",JSON.stringify(obj))
      state.user=obj;
    }
  },
  actions: {
    //动作触发，触发的一定是mutations,不能够直接修改state
    loginAction(context,obj){
      context.commit('login',obj);
    }
  },
  modules: {
  }
})

